package com.visual.echart.common;

import com.visual.echart.model.BaseResp;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;

/**
 * 简介说明:全局异常处理器
 *
 * @author: biboyuzhou
 * @date: 2025/06/14 18:26:40
 * @version:1.0
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    public ResponseEntity<BaseResp> handleGlobalException(Exception ex, WebRequest req) {
        ex.printStackTrace();
        BaseResp baseResp = new BaseResp();
        baseResp.fillErrorResp(baseResp);

        return new ResponseEntity<>(baseResp, HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
